<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2022-11-22
 * Time: 20:39
 */

namespace App\server\wechat;
use App\model\Xbvido;
use think\facade\Db;
use EasyWeChat\Kernel\Messages\Text;
class ResponseText
{
    private $message;
    public function __construct($message)
    {
        $this->message=$message;
    }

    public function handle()
    {
        $message=$this->message;
        $c=preg_match('/^(\d{5,6})$/',$message['Content']);
        //$arr=['match'=>$c,'Content'=>$message['Content']];

        if($c){
            $vid=(int)$message['Content'];
            $x=Xbvido::where('vid',$vid)->find();
            if(!$x){
                return '末查到对应数据';
            }
            $x->inc('isxz',1)->update();
            $arr=$x->toArray();
            if($arr['xltq']){
                return new Text( $vid.'_'.$arr['title'].'.7z');
            }
            return new Text( $arr['xl']);
        }
    }
}